﻿@model IEnumerable<MVC_Store.Models.ViewModels.Cart.CartVM>

@{
    ViewBag.Title = "Cart Details";

    int count = 1;
}

<h2>Cart Details</h2>

@if (ViewBag.Message != null)
{
    <h3>@ViewBag.Message</h3>
}
else
{
    <div class="ajaxbg">
        <span>
            <img src="~/Content/img/ajax-loader.gif" height="100" width="150" />
        </span>
    </div>


    <table class="table">
        <tr>

            <th>
                Name
            </th>
            <th>
                Quantity
            </th>
            <th>
                Price
            </th>

            <th>
                Image
            </th>

            <th>
                <!--Свободная ячейка для кнопок изменения количества товаров-->
            </th>

            <th>
                Total
            </th>

            <th>

            </th>
        </tr>

        @foreach (var item in Model)
        {
            <tr>

                <td>
                    @Html.DisplayFor(modelItem => item.ProductName)
                </td>
                <td class="qty@(item.ProductId)">
                    @Html.DisplayFor(modelItem => item.Quantity)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Price)€
                </td>

                <td>
                    <img src="/Images/Uploads/Products/@item.ProductId/Thumbs/@item.Image" />
                </td>

                <td>
                    <a href="#" class="incproduct" data-id="@item.ProductId">+</a>
                    <a href="#" class="decproduct" data-id="@item.ProductId">-</a>
                    <a href="#" class="removeproduct" data-id="@item.ProductId">Remove</a>
                </td>

                <td class="total@(item.ProductId)">
                    @Html.DisplayFor(modelItem => item.Total)€
                </td>


            </tr>
        }

        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td class="grandtotal"><b>Grand total: </b><span>@ViewBag.GrandTotal €</span></td>
        </tr>

    </table>

<div class="paypaldiv">
    <form class="paypalform" action="https://www.sandbox.paypal.com/us/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1" />
        <input type="hidden" name="business" value="sb-rjgdb30115@business.example.com">

        @foreach (var item in Model)
        {
            <input type="hidden" name="item_name_@count" value="@item.ProductName">
            <input type="hidden" name="amount_@count" value="@item.Price">
            <input type="hidden" name="quantity_@count" value="@item.Quantity">
            count++;
        }

        <input type="hidden" name="currency_code" value="EUR">
        
        <div style="display: none">
            <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
        </div>
    </form>
</div>

    <br />
    <a href="#" class="placeorder btn btn-primary float-right">Checkout</a>

}

@section Scripts
{
    <script src="~/Content/ShopJS/IncrementProductScript.js"></script>
}